﻿using Inovout.Cloud.DataStore.Models;
using Inovout.Cloud.DataWarehouse.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace Inovout.Cloud.DataWarehouse.Web.Utility
{
    public class CommonUtils
    {
        public static DataCollectionPropertyType viewTypeTransform(PropertyType type) {
            switch (type) { 
                case PropertyType.Bool:
                    return DataCollectionPropertyType.Bool;
                case PropertyType.ByteArray:
                    return DataCollectionPropertyType.ByteArray;
                case PropertyType.DateTime:
                    return DataCollectionPropertyType.DateTime;
                case PropertyType.Double:
                    return DataCollectionPropertyType.Double;
                case PropertyType.Int16:
                case PropertyType.Int32:
                case PropertyType.Int64:
                    return DataCollectionPropertyType.Int;
                default:
                    return DataCollectionPropertyType.String;
            }
        }


        public static DataCollectionPropertyType stringTransform(string type)
        {
            type = type.ToLower();
            switch (type)
            {
                case "entity":
                    return DataCollectionPropertyType.Entity;
                case "set":
                    return DataCollectionPropertyType.Set;
                default:
                    throw new NotSupportedException();
            }
        }


        public static Operation stringTransformOpertion(string type)
        {
            switch (type.ToLower())
            {
                case "equal":
                    return Operation.Equal;
                case "and":
                    return Operation.And;

                case "or":
                    return Operation.Or;
                default:
                    throw new NotSupportedException();
            }
        }
    }
}